widget: Fix checks in gtk_widget_snapshot()
authorTimm Bäder <mail@baedert.org>
Sun, 26 Mar 2017 10:45:50 +0000 (12:45 +0200)
committerTimm Bäder <mail@baedert.org>
Fri, 31 Mar 2017 07:50:39 +0000 (09:50 +0200)
If the widget isn't drawable anyway, just return;

If the widget needs an allocate, print a warning, since it indicates a
problem in the widget workflow (e.g. forgot to size_allocate a child
widget).

This maches the previous checks in gtk_widget_draw (with the same
problems).

gtk/gtkwidget.c

index 001a190850e5d97ac9549d68f062da5b00aecacf..44359545b60b0817fdf56bc6c194e113e4baaffb 100644 (file)
@@ -15440,9 +15440,15 @@ gtk_widget_snapshot (GtkWidget   *widget,
   double opacity;
   cairo_rectangle_int_t offset_clip;
 
-  if (_gtk_widget_get_alloc_needed (widget))
+  if (!_gtk_widget_is_drawable (widget))
     return;
 
+  if (_gtk_widget_get_alloc_needed (widget))
+    {
+      g_warning ("Trying to snapshot %s %p without a current allocation", G_OBJECT_TYPE_NAME (widget), widget);
+      return;
+    }
+
   priv = widget->priv;
   offset_clip = priv->clip;
   offset_clip.x -= priv->allocation.x;